package com.example.datn.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.datn.R;
import com.example.datn.manager.ResourceManager;
import com.example.datn.manager.SongManager;
import com.example.datn.objects.AlbumObject;
import com.example.datn.objects.SongObject;

public class SongItemInAlbumAdapter extends ArrayAdapter<SongObject>{
	
	Activity context = null;
	ArrayList<SongObject> myArray = null;
	int layoutId;
	private static LayoutInflater inflater = null;
	
	public SongItemInAlbumAdapter(Activity context, int layoutid, ArrayList<SongObject> arr) {
		super(context, layoutid, arr);
		
		this.context = context;
		this.layoutId = layoutid;
		this.myArray = arr;
		
		inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {		
		View vi = convertView;
		ViewHolder holder;
		
		if (convertView == null) {
			vi = inflater.inflate(R.layout.my_song_item_in_album, null);			
			holder = new ViewHolder();
			holder.tv_item_song_name = (TextView)vi.findViewById(R.id.tv_song_in_album_name);
			holder.tv_item_status = (TextView)vi.findViewById(R.id.tv_status_album);
			
			vi.setTag(holder);
		}
		else{
			holder = (ViewHolder) vi.getTag();
		}
		
		SongObject song = myArray.get(position);		
		holder.tv_item_song_name.setText(song.songName);				
//		if(song.getSongNo() == SongManager.getInstance().getCurrentSong().getSongNo())
//			holder.tv_item_status.setText("playing");
		return vi;		
	}

	private static class ViewHolder {
	    public TextView tv_item_song_name;
	    public TextView tv_item_status;
	}
}
